package com.nxcy.servlet;

import com.nxcy.utils.DBUtil;
import com.nxcy.utils.DataDic;

import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class InitDataDicServlet extends HttpServlet {
    @Override
    public void init() throws ServletException {
        System.out.println("开始装载行政区划数据到内存中......");
        DBUtil db = new DBUtil();
        try {
            ResultSet rs = db.query("select code,name from sys_xzqh");
            while (rs.next()) {
                DataDic.zxqh.put(rs.getString("code"), rs.getString("name"));
            }

            db.close();
            System.out.println("行政区划数据装载完毕......");

        } catch (Exception e) {
            e.printStackTrace();
        }


    }

}
